package com.hsmpay.yl8583.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.UnsupportedEncodingException;

public class SpringUtil {
	private static final ApplicationContext app= buildApplicationContext();
    private static ApplicationContext buildApplicationContext() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return  new ClassPathXmlApplicationContext("anxinybConfig.xml");
        }
        catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
    
    public static ApplicationContext getApplicationContext() {
    		return app;
    }
    
    public static void main(String args[]) throws UnsupportedEncodingException{
    	Field filed = (Field) app.getBean("bit4");
    	filed.valueof("100");
    	Field filed1 = (Field) app.getBean("bit4");
    	filed1.valueof("600");
    	
//    	log.debug(filed.getValue());
//    	log.debug(filed1.getValue());
//    	log.debug(filed1.equals(filed));
    }
}